<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //ESS 构造函数继承写法
        function Phone(brand, price) {
            this.brand = brand
            this.price = price
        }
        Phone.prototype.call = function() {
            console.log("打电话...")
        }

        //子类
        function SmartPhone(brand, price, color, size) {
            Phone.call(this, brand, price) //调用父类构造函数 new Phone(brand, price)
            this.color = color
            this.size = size
        }

        //设置子级构造函数的原型
        SmartPhone.prototype = new Phone
        SmartPhone.prototype.constructor = SmartPhone

        //子类方法
        SmartPhone.prototype.playGame = function() {
            console.log('我可以玩游戏')
        }
        let chuizi = new SmartPhone('锤子', 2499, '黑色', '5.5英寸')
        console.log(chuizi)
    </script>
</body>
</html>